﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>部门信息</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link href="~/Content/X-admin/css/font.css" rel="stylesheet" />
    <script src="~/Content/X-admin/lib/layui/layui.js"></script>
    <link href="~/Content/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/Content/X-admin/js/jquery.min.js"></script>
    <script src="~/Content/X-admin/js/xadmin.js"></script>
    <script src="~/Content/Scripts/System/systemFrame.js"></script>
    <script src="~/Content/Scripts/System/Common.js"></script>

</head>
<body>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5" name="qForm" id="qForm">
                            <div class="layui-inline layui-show-xs-block">

                                <input type="text" name="depCode" placeholder="部门编码" autocomplete="off" class="layui-input" id="depCode">
                            </div>
                            <div class="layui-inline layui-show-xs-block">

                                <input type="text" name="depName" placeholder="部门名称" autocomplete="off" class="layui-input" id="depName">
                            </div>

                            <div class="layui-inline layui-show-xs-block">
                                <button class="layui-btn" lay-filter="sreach" id="btn-view" type="button" onclick="loadData()"><i class="layui-icon">&#xe615;</i></button>
                            </div>
                        </form>
                    </div>
                    <div class="layui-card-header">

                        <button class="layui-btn" id="btn-sync" type="button" onclick="Sync('dept')"><i class="layui-icon">&#xe641;</i>数据同步</button>
                        <span style="margin-left: 20px; padding: 7px; background-color: #bababa;font-size:xx-small">数据停用</span>
                    </div>
                    <div class="layui-card-body layui-table-body layui-table-main" id="layui-table-main">
                        <table class="layui-hide" id="list" lay-filter="list"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

</html>
<script type="text/html" id="barDemo">
    {{# if(d.isSync=='N'){}}
    <a title="编辑信息" href="javascript:;" lay-event="dEdit" id="update"><i class="layui-icon">&#xe642;</i></a>
    <a title="删除信息" href="javascript:;" lay-event="dDel" id="del"><i class="layui-icon">&#xe640;</i></a>
    {{# }}}

</script>
<script>
    /**
     * 加载数据
     * **/
    function loadData() {
        layui.use('table', function () {

            var conditon = JSON.stringify(FormToJson("qForm"));
            var table = layui.table;
            table.render({
                elem: '#list'
                , cols: [[ //标题栏
                    { field: 'id', title: 'ID', width: 80 }
                    , { field: 'depCode', align: 'center', title: '仓库编码', width: '25%' }
                    , { field: 'depName', align: 'center', title: '仓库名称', width: '25%' }
                    , { field: 'status', align: 'center', title: '数据状态', width: '24%' }
                    , { field: 'isSync', align: 'center', title: '同步数据', width: '24%' }
                ]], done: function (res, curr, count) {
                    $("[data-field='id']").css('display', 'none');//隐藏列
                    $.each(res['data'], function (i, obj) {
                        var status = obj["status"];
                        if (status == "N") {
                            TableRowColor('layui-table-main', i, '#bababa');
                        }
                    });
                }
                , url: "../Basis/GetDataList?dataType=dept&condition=" + conditon
                , skin: 'row' //表格风格
                , even: true
                , page: true //是否显示分页
                , limits: [15, 20, 30]
                , limit: 15 //每页默认显示的数量
            });
            //监听工具条
            table.on('tool(list)', function (obj) {
                var data = obj.data;
                //if (obj.event == 'dEdit') {
                //    if (data.isSync == 'Y') {
                //        layer.msg("同步数据禁止修改！");
                //    } else {
                //        InfoOpenPage('../Basis/UpdateDeptInfo?dataId=' + data.id, data.depName + '-信息修改', '65%', '80%')
                //    }
                //}
                //else {
                //    if (data.isSync == "Y") {
                //        layer.msg("同步数据禁止删除！");
                //    } else {
                //        layer.confirm('确定删除此仓库？', function (index) {
                //            $.ajax({
                //                url: "../Basis/DelDepartment",
                //                data: { dataId: data.id },
                //                type: 'post',
                //                success: function (rsl) {
                //                    if (rsl.Result) {
                //                        layer.msg('删除成功！');
                //                    } else {
                //                        layer.msg('删除失败！');
                //                    }
                //                    loadData()
                //                }
                //            })
                //            layer.close('index')
                //        })
                //    }
                //}

            });

        });
    }
    $(function () {
        WebPowersShow();
        loadData();
    })


   
</script>